<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>springboot+layui Demo</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="common/css/menuIndex.css">
    <link rel="stylesheet" href="common/css/main.css">
    <link rel="icon" href="common/images/kaishun.jpg" type="image/x-icon" />
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">springboot+layui Demo</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="common/images/kaishun.jpg" class="layui-nav-img">
                    <span class="userName">
                        <!--用户名-->
                    </span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item logout"><a href="javascript:;">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <!--菜单目录-->
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div id="content">
            <h1>
                基本说明
                <small>本demo采用springboot+layui编写，包含基本的JWT校验、公共返回值封装、统一异常处理、日志打印、前端ajax基本请求封装</small>
                <small>jdk1.8，mysql5.6，redis仅用于发送短信以及用户id与token的绑定，可自行修改后移除</small>
                <small>功能方便仅实现了基本的登录注册、忘记密码，用户、角色、菜单的增删改查，以及基础的权限分配</small>
                <small>发送短信采用的时阿里云的demo，可按自己的配置修改，本示例中配置已清空，按需修改，也可直接删除</small>
                <small>添加服务监控功能</small>
                <small>可优化的部分还有很多，不喜勿喷，仅供新手参考</small>
            </h1>
            <div class="slideshow">
                <div class="slideshow-image" style="background-image: url('common/images/1.jpg')"></div>
                <div class="slideshow-image" style="background-image: url('common/images/2.jpg')"></div>
                <div class="slideshow-image" style="background-image: url('common/images/3.jpg')"></div>
                <div class="slideshow-image" style="background-image: url('common/images/4.jpg')"></div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <div class="layui-footer" style="text-align: center">
            <div>码云地址:<a href="https://gitee.com/zhoukaishun">https://gitee.com/zhoukaishun</a></div>
        </div>
    </div>
</div>
<script src="layui/layui.js"></script>
<script src="/common/js/home/index.js"></script>
<script src="layui/jquery-3.3.1.min.js"></script>
<script src="/common/js/jstree.js"></script>
<script src="/common/js/ajax.js"></script>
<script src="/common/js/utils.js"></script>

</body>
<script>

    layui.use('layer', function(){
        var layer = layui.layer;
    });
    AsyncPost("/tbUser/info",null,function (data) {
        $(".userName").text(data.data.userName);
    });

    $(".logout").click(function () {
        layer.confirm('是否退出？', {
            btn: ['确定', '取消'],
        }, function(index, layero){
            AsyncPost("/tbUser/logout", null, function (result) {
                localStorage.token = null;
                window.location.href = "/"
            })
        });

    })

    SyncGet("/tbMenu/getMenus",null,function (data) {
        var $li,$menu_dl;
        $.each(data.data,function (index,item) {
            if(item.number.length == 5){
                /*添加layui-nav-itemed类名，默认展开*/
                /*$li = $('<li class="layui-nav-item layui-nav-itemed"></li>');*/
                $li = $('<li class="layui-nav-item"></li>');
                var $menu_a_ = $('<a href="javascript:;">'+item.name+'</a>');
                $li.append($menu_a_);
                $menu_dl = $('<dl class="layui-nav-child"></dl>');
                $li.append($menu_dl);
                $("ul.layui-nav-tree").append($li);
            }else if(item.number.length == 8){
                var $dd = $('<dd><a href="javascript:;" data-href="'+item.url+'">'+item.name+'</a></dd>');
                $menu_dl.append($dd);
            }
        })
    });

</script>
</html>